package cn.yfxu.server.controller;


import cn.yfxu.server.pojo.Department;
import cn.yfxu.server.pojo.Result;
import cn.yfxu.server.service.IDepartmentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author yfxu
 * @since 2021-03-10
 */
@RestController
@RequestMapping("/system/basic/department")
public class DepartmentController {

    private IDepartmentService departmentService;

    public DepartmentController(IDepartmentService departmentService) {
        this.departmentService = departmentService;
    }

    @ApiOperation(value = "获取所有部门")
    @RequestMapping(method = RequestMethod.GET, value = "/")
    public List<Department> getAllDepartments() {
        return departmentService.getAllDepartments();
    }

    @ApiOperation(value = "添加部门")
    @RequestMapping(method = RequestMethod.POST, value = "/")
    public Result addDep(@RequestBody Department department) {
        return departmentService.addDep(department);
    }

    @ApiOperation(value = "删除部门")
    @RequestMapping(method = RequestMethod.DELETE, value = "/{id}")
    public Result delDep(@PathVariable Integer id) {
        return departmentService.delDep(id);
    }

}
